package com.wsl.config;

import com.wsl.Date.DateUtil;

import javax.annotation.PreDestroy;
import javax.persistence.*;
import java.util.Date;

/**
 * @Author: wsl
 * @Date: 2022/3/30 10:10
 */

//自定义实体类监听类

public class entityMonitor {


    @PrePersist
    public void preSave(Object entity) {
        System.out.println("开始保存--" + DateUtil.dateToChineseTime(new Date()) + "--" + entity.toString());
    }

    @PostPersist
    public void postSave(Object entity) {
        System.out.println("结束保存--" + DateUtil.dateToChineseTime(new Date()) + " -- " + entity.toString());
    }


    @PreRemove
    public void preDel(Object entity) {
        System.out.println("开始删除--" + DateUtil.dateToChineseTime(new Date()) + " -- " + entity.toString());
    }

    @PostRemove
    public void postDel(Object entity){
        System.out.println("结束删除--" + DateUtil.dateToChineseTime(new Date()) + " -- " + entity.toString());
    }


    @PreUpdate
    public void preUpd(Object entity) {
        System.out.println("开始修改--" + DateUtil.dateToChineseTime(new Date()) + " -- " + entity.toString());
    }

    @PostUpdate
    public void postUpd(Object entity){
        System.out.println("结束修改--" + DateUtil.dateToChineseTime(new Date()) + " -- " + entity.toString());
    }



}